package cn.dankal.flyaudio.store;

import android.view.View;
import android.widget.TextView;

import java.util.List;

import androidx.recyclerview.widget.RecyclerView;
import cn.dankal.basiclib.base.activity.BaseActivity;
import cn.dankal.basiclib.pojo.LogisticsEntity;
import cn.dankal.flyaudio.R;
import cn.dankal.flyaudio.adapter.LogisticsAdapter;
import cn.dankal.flyaudio.contract.LogisticsContract;
import cn.dankal.flyaudio.friend.utils.takevideo.utils.LogUtils;
import cn.dankal.flyaudio.presenter.LogisticsPresenter;

/**
 * <pre>
 *     e-mail : junfeng.nie@duntech.com.cn
 *     time   : 22/7/2020
 *     desc   :
 *     version: cn.dankal.flyaudio.store
 *     Copyright: Copyright（c）2018
 *     Company:
 * </pre>
 *
 * @author niejunfeng
 */
public class LogisticsActivity extends BaseActivity implements LogisticsContract.View {
    private LogisticsPresenter mPresenter;
    private LogisticsAdapter mAdapter;
    private TextView tvNumber;
    private TextView tvType;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_logistics;
    }

    @Override
    protected void initComponents() {
        String orderUuid = getIntent().getStringExtra("orderUuid");
        String number = getIntent().getStringExtra("number");
        String type = getIntent().getStringExtra("type");
        String orderType = getIntent().getStringExtra("orderType");
        LogUtils.e(orderUuid + "----" + number + "----" + type + "----" + orderType);
        tvNumber = findViewById(R.id.tv_number_text);
        tvType = findViewById(R.id.tv_type_text);

        findViewById(R.id.iv_onback).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onBackPressed();
            }
        });
        tvNumber.setText(orderUuid);
        tvType.setText(orderType);
        mAdapter = new LogisticsAdapter();
        RecyclerView mRv = findViewById(R.id.mRv);
        mRv.setAdapter(mAdapter);
        mPresenter = new LogisticsPresenter();
        mPresenter.attachView(this);

        mPresenter.shipment(orderUuid, type);
    }

    @Override
    public void onSuccess(List<LogisticsEntity> logisticsEntities) {
        mAdapter.addDatas(logisticsEntities, false);
    }

    @Override
    public void onError() {

    }
}
